<template>
	<div class="table-box">
		<proTable
			ref="proTableRef"
			:columns="columns"
			:toolButton="true"
			:requestApi="api.GetCompetitionRuleInfoListApi"
			:dataCallback="dataCallback"
		>
			<template #tableHeader>
				<el-button type="primary" :icon="CirclePlus" @click="handleAddRule">添加规则</el-button>
			</template>
			<template #operation="scope">
				<el-space wrap>
					<el-tag @click="handleEidit(scope.row.id)" style="cursor: pointer"> 编辑 </el-tag>
					<el-tag
						@click="handleClose(scope.row)"
						style="cursor: pointer"
						:type="scope.row.state == '禁用' ? 'success' : 'danger'"
					>
						{{ scope.row.state == "禁用" ? "启用" : "禁用" }}
					</el-tag>
				</el-space>
			</template>
		</proTable>
		<el-dialog v-model="isShow" @close="handleCancel(ruleFormRef)" width="850px" :title="dialogType + '规则'">
			<el-form
				ref="ruleFormRef"
				:model="RuleFrom"
				:rules="rules"
				label-width="auto"
				label-position="left"
				width="60%"
				class="demo-ruleForm"
				status-icon
			>
				<el-form-item label="规则名称：" prop="name">
					<el-input style="width: auto" placeholder="请输入" v-model="RuleFrom.name" />
				</el-form-item>
				<el-form-item label="适用项目：" prop="project">
					<el-select v-model="RuleFrom.project" multiple placeholder="请选择">
						<el-option v-for="item in projectList" :key="item.id" :label="item.name" :value="item.id" />
					</el-select>
				</el-form-item>
				<el-form-item label="规则类型：" prop="type">
					<el-radio-group @change="handleChangeType" v-model="RuleFrom.type">
						<el-radio :label="0">成绩计算规则</el-radio>
						<el-radio :label="1">惩罚规则</el-radio>
					</el-radio-group>
				</el-form-item>
				<div v-show="RuleFrom.type == 0" class="gradeType">
					<el-form-item required label="场次（决赛）成绩计算规则：">
						<el-radio-group @change="RuleFrom.finalCircle = 0" v-model="RuleFrom.finalRule">
							<el-radio :label="0">比赛时间内，跑圈最多且用时最少者排名靠前；相同圈数看跑圈用时，用时者排名靠前</el-radio>
							<el-radio :label="1">比赛时间内，跑圈最多者排名靠前</el-radio>
							<el-radio :label="2"
								>比赛时间内，跑
								<el-input
									:disabled="RuleFrom.finalRule !== 2"
									style="width: 80px; margin: 0 5px"
									v-model.number="RuleFrom.finalCircle"
									size="small"
									placeholder="请输入"
								/>
								圈，用时最少者排名靠前
							</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item prop="bestFiled" label="预赛进决赛成绩计算规则">
						<el-input style="width: auto" v-model.number="RuleFrom.bestFiled" min="0" placeholder="请输入3以内的整数">
							<template #prepend> 预赛3场，取最优 </template>
							<template #append> 场 </template>
						</el-input>
					</el-form-item>
					<el-form-item prop="preliminaryRule" :required="false" label=" ">
						<el-select v-model="RuleFrom.preliminaryRule" placeholder="请选择" style="width: 115px">
							<el-option label="累计" :value="0" />
							<el-option label="平均" :value="1" />
						</el-select>
						<span style="margin-left: 10px">成绩较高者排名靠前</span>
					</el-form-item>
					<el-form-item prop="finalPeopleNum" :required="false" label=" ">
						<el-input style="width: auto" v-model.number="RuleFrom.finalPeopleNum" placeholder="请输入名次数">
							<template #prepend> 取 </template>
							<template #append> 名进入决赛 </template>
						</el-input>
					</el-form-item>
					<el-form-item prop="finalDeductTime" label="预赛统计：">
						<div>
							<el-input style="width: auto" v-model.number="RuleFrom.finalDeductTime" placeholder="请输入扣除分钟数">
								<template #prepend> 扣除分钟数 </template>
								<template #append> 分钟 </template>
							</el-input>
						</div>
					</el-form-item>
					<el-form-item prop="singleMinTime" label="单次过点最低时间：">
						<div>
							<el-input style="width: auto" v-model.number="RuleFrom.singleMinTime" placeholder="请输入">
								<template #append> 秒钟 </template>
							</el-input>
						</div>
					</el-form-item>
					<el-form-item prop="isFirstCircled">
						<template #label>
							<div>
								第一次过点是否需要增加圈数：
								<el-tooltip effect="dark" content="小于单次过点最低时间不加圈，大于单次过点最低时间加圈" placement="top">
									<el-icon style="margin-left: 4px" :size="12">
										<Warning />
									</el-icon>
								</el-tooltip>
							</div>
						</template>
						<el-radio-group v-model="RuleFrom.isFirstCircled">
							<el-radio :label="true">是</el-radio>
							<el-radio :label="false">否</el-radio>
						</el-radio-group>
					</el-form-item>
				</div>
				<div v-show="RuleFrom.type == 1" class="punishment">
					<div class="rulrBox">
						<div class="rulesTitle">
							<span>漏标惩罚规则</span>
						</div>
						<div class="item" style="margin-bottom: 10px">
							<el-radio @change="handleChangeLeakageRule" v-model="RuleFrom.leakageRule" :label="0" size="large">漏标 </el-radio>
							<el-input
								:disabled="RuleFrom.leakageRule == 1"
								style="width: auto"
								v-model.number="RuleFrom.oneLeakageNum"
								placeholder="请输入"
							>
								<template #append> 个 </template>
							</el-input>
							，
							<el-input
								:disabled="RuleFrom.leakageRule == 1"
								style="width: auto"
								v-model.number="RuleFrom.oneLeakageCircle"
								placeholder="请输入"
							>
								<template #prepend> 扣 </template>
								<template #append> 圈 </template>
							</el-input>
						</div>
						<div class="item">
							<el-radio @change="handleChangeLeakageRule" v-model="RuleFrom.leakageRule" :label="1" size="large"
								>漏标第
							</el-radio>
							<el-input
								:disabled="RuleFrom.leakageRule == 0"
								style="width: auto"
								v-model.number="RuleFrom.twoLeakageNum"
								placeholder="请输入"
							>
								<template #append> 个 </template>
							</el-input>
						</div>
						<div class="item">
							<el-radio-group
								:disabled="RuleFrom.leakageRule == 0"
								@change="handleTwoLeakageType"
								v-model="RuleFrom.twoLeakageType"
								class="ml-4"
							>
								<el-radio :label="0" size="large"
									>扣圈
									<el-input
										:disabled="RuleFrom.twoLeakageType == 1 || RuleFrom.leakageRule == 0"
										style="margin-left: 10px"
										v-model.number="RuleFrom.twoLeakageCircle"
										placeholder="请输入"
									>
										<template #append> 圈 </template>
									</el-input>
								</el-radio>
								<el-radio :label="1" style="margin-left: 20px" size="large"
									>加时
									<el-input
										:disabled="RuleFrom.twoLeakageType == 0 || RuleFrom.leakageRule == 0"
										style="margin-left: 10px"
										v-model.number="RuleFrom.twoLeakageAddTime"
										placeholder="请输入"
									>
										<template #append> 秒 </template>
									</el-input>
								</el-radio>
							</el-radio-group>
						</div>
						<div class="item">
							<el-input
								:disabled="RuleFrom.leakageRule == 0"
								style="width: auto"
								v-model.number="RuleFrom.twoLeakageThenNum"
								placeholder="请输入"
							>
								<template #prepend> 此后则每漏标 </template>
								<template #append> 个 </template>
							</el-input>
							，
							<el-input
								:disabled="RuleFrom.leakageRule == 0"
								style="width: auto"
								v-model.number="RuleFrom.twoLeakageThenCircle"
								placeholder="请输入"
							>
								<template #prepend>
									<el-select style="width: 80px" v-model="RuleFrom.twoLeakageAddType">
										<el-option label="扣圈" :value="0" />
										<el-option label="加时" :value="1" />
									</el-select>
								</template>
								<template #append> {{ RuleFrom.twoLeakageAddType ? "秒" : "圈" }} </template>
							</el-input>
						</div>
					</div>
					<div class="rulrBox">
						<div class="rulesTitle">
							<span>红黄牌惩罚规则</span>
						</div>
						<div class="item">
							<el-input style="width: auto" v-model.number="RuleFrom.yellowCardNum" placeholder="请输入">
								<template #append> 个黄牌 </template>
							</el-input>
							，
							<el-input style="width: auto" v-model.number="RuleFrom.yellowCardCircle" placeholder="请输入">
								<template #prepend> 扣 </template>
								<template #append> 圈 </template>
							</el-input>
						</div>
						<div class="item">
							<el-input style="width: auto" v-model.number="RuleFrom.yellowCardTurnRedCardNum" placeholder="请输入">
								<template #append> 个黄牌 </template>
							</el-input>
							，
							<el-input style="width: auto" v-model.number="RuleFrom.trunRedCardNum" placeholder="请输入">
								<template #prepend> 得 </template>
								<template #append> 红牌 </template>
							</el-input>
						</div>
						<div class="item">
							<el-input style="width: auto" v-model.number="RuleFrom.redCardNum" placeholder="请输入">
								<template #append> 红牌本场成绩无效 </template>
							</el-input>
						</div>
					</div>
				</div>
			</el-form>
			<template #footer>
				<span class="dialog-footer">
					<el-button @click="handleCancel(ruleFormRef)">取消</el-button>
					<el-button type="primary" @click="handleSubmit(ruleFormRef)"> 确定 </el-button>
				</span>
			</template>
		</el-dialog>
	</div>
</template>
<script lang="ts" setup name="logs">
import { ref, computed, reactive } from "vue";
import api from "@/api/modules/competitionRuleInfo";
import { ColumnProps } from "@/components/ProTable/interface";
import { ElMessageBox, ElMessage } from "element-plus";
import proTable from "@/components/ProTable/index.vue";
import type { FormInstance, FormRules, Action } from "element-plus";
import project from "@/api/modules/project";
import { CirclePlus } from "@element-plus/icons-vue";
// 获取 ProTable 元素，调用其获取刷新数据方法（还能获取到当前查询参数，方便导出携带参数）
const proTableRef = ref();
//添加规则，编辑规则显示隐藏
const isShow = ref<boolean>(false);
//模态框标题控制
const dialogType = ref<string>("添加");
//表单实例
const ruleFormRef = ref<FormInstance>();
//所有项目下拉列表
const projectList = ref<Array<any>>([]);
// dataCallback 是对于返回的表格数据做处理，如果你后台返回的数据不是 datalist && total && pageNum && pageSize 这些字段，那么你可以在这里进行处理成这些字段
const dataCallback = (data: any) => {
	return {
		list: data.data,
		total: data.totalCount
	};
};

//表单类型
interface RuleFrom {
	id?: string;
	name: string;
	project: any;
	type: number;
	content: string;
	state: number;
	finalRule: number;
	finalCircle: number;
	bestFiled: number;
	preliminaryRule: number;
	finalPeopleNum: number;
	finalDeductTime: number;
	singleMinTime: number;
	isFirstCircled: boolean;
	leakageRule: number;
	oneLeakageNum: number;
	oneLeakageCircle: number;
	twoLeakageNum: number;
	twoLeakageType: number;
	twoLeakageCircle: number;
	twoLeakageAddTime: number;
	twoLeakageThenNum: number;
	twoLeakageAddType: number;
	twoLeakageThenCircle: number;
	yellowCardNum: number;
	yellowCardCircle: number;
	yellowCardTurnRedCardNum: number;
	trunRedCardNum: number;
	redCardNum: number;
}
//添加规则按钮
const handleAddRule = () => {
	dialogType.value = "添加";
	isShow.value = true;
};

//获取所有项目列表
const getProjectList = async () => {
	let res = await project.GetProjectInfoApi();
	let { data } = res.result;
	projectList.value = data;
};
getProjectList();

const RuleFrom = ref<RuleFrom>({
	id: "",
	name: "", //规则名称
	project: [], //适用项目
	type: 0, //规则类型 0:成绩计算规则 1:惩罚规则
	content: "", //规则内容
	state: 1, //状态 0:禁用 1:启用（默认传启用）
	finalRule: 0, //决赛成绩计算规则 0：规则1，1：规则2，2：规则3
	finalCircle: 0, //决赛圈数
	bestFiled: 1, //预赛成绩最优场数
	preliminaryRule: 0, //预赛场数计算规则 0：累计 1：平均
	finalPeopleNum: 0,
	finalDeductTime: 0,
	isFirstCircled: false,
	singleMinTime: 0,
	leakageRule: 0, //漏标规则 0：漏标规则1，1：漏标规则2
	oneLeakageNum: 0, //漏标规则1漏标数量
	oneLeakageCircle: 0, //漏标规则1扣圈
	twoLeakageNum: 0, //标规则2漏标数量
	twoLeakageType: 0, //漏标规则2惩罚类型 0：圈，1：秒
	twoLeakageCircle: 0, //漏标规则2扣圈数量
	twoLeakageAddTime: 0, //漏标规则2加时
	twoLeakageThenNum: 0, //漏标规则2此后漏标数量
	twoLeakageAddType: 0,
	twoLeakageThenCircle: 0, //漏标规则2此后漏标数量扣圈/加时
	yellowCardNum: 0, //黄牌数量
	yellowCardCircle: 0, //黄牌数量扣圈数
	yellowCardTurnRedCardNum: 0, //黄牌得红牌的数量
	trunRedCardNum: 0, //黄牌得红牌得数量
	redCardNum: 0 //红牌数量成绩无效
});
const validateField = (rule: any, value: any, callback: any) => {
	if (value <= 0) {
		callback(new Error("数值不能小于0"));
		return;
	}
	callback();
};
//表单验证
const rules = reactive<FormRules>({
	name: [{ required: true, message: "请输入规则名称！", trigger: "blur" }],
	project: [{ required: true, message: "请选择项目！", trigger: "change" }],
	type: [{ required: true, message: "规则类型为必选项!", trigger: "change" }],
	finalDeductTime: [{ required: true, validator: validateField, trigger: "blur" }],
	singleMinTime: [{ required: true, validator: validateField, trigger: "blur" }],
	isFirstCircled: [{ required: true, message: "第一次过点是否需要增加圈数!", trigger: "change" }],
	finalRule: [{ required: true, message: "请选择规则", trigger: "change" }],
	bestFiled: [{ required: true, validator: validateField, trigger: "blur" }],
	preliminaryRule: [{ required: true, message: "请选择规则", trigger: "change" }],
	finalPeopleNum: [{ required: true, validator: validateField, trigger: "blur" }]
});
//重置表单数据
const flushed = () => {
	RuleFrom.value = {
		id: "",
		name: "", //规则名称
		project: [], //适用项目
		type: 0, //规则类型 0:成绩计算规则 1:惩罚规则
		content: "", //规则内容
		state: 1, //状态 0:禁用 1:启用（默认传启用）
		finalRule: 0, //决赛成绩计算规则 0：规则1，1：规则2，2：规则3
		finalCircle: 0, //决赛圈数
		bestFiled: 1, //预赛成绩最优场数
		preliminaryRule: 0, //预赛场数计算规则 0：累计 1：平均
		finalPeopleNum: 0,
		finalDeductTime: 0,
		singleMinTime: 0,
		isFirstCircled: false,
		leakageRule: 0, //漏标规则 0：漏标规则1，1：漏标规则2
		oneLeakageNum: 0, //漏标规则1漏标数量
		oneLeakageCircle: 0, //漏标规则1扣圈
		twoLeakageNum: 0, //标规则2漏标数量
		twoLeakageType: 0, //漏标规则2惩罚类型 0：圈，1：秒
		twoLeakageCircle: 0, //漏标规则2扣圈数量
		twoLeakageAddTime: 0, //漏标规则2加时
		twoLeakageThenNum: 0, //漏标规则2此后漏标数量
		twoLeakageAddType: 0, //标规则2此后漏标惩罚类型 0：圈，1：秒
		twoLeakageThenCircle: 0, //漏标规则2此后漏标数量扣圈/加时
		yellowCardNum: 0, //黄牌数量
		yellowCardCircle: 0, //黄牌数量扣圈数
		yellowCardTurnRedCardNum: 0, //黄牌得红牌的数量
		trunRedCardNum: 0, //黄牌得红牌得数量
		redCardNum: 0 //红牌数量成绩无效
	};
};
//扣圈加时切换
const handleTwoLeakageType = (val: number) => {
	if (val == 0) {
		RuleFrom.value.twoLeakageAddTime = 0;
		return;
	}
	RuleFrom.value.twoLeakageCircle = 0;
};

//漏标惩罚规则切换
const handleChangeLeakageRule = (val: number) => {
	if (val == 1) {
		RuleFrom.value.oneLeakageNum = 0;
		RuleFrom.value.oneLeakageCircle = 0;
		return;
	}
	RuleFrom.value.twoLeakageNum = 0;
	RuleFrom.value.twoLeakageType = 0;
	RuleFrom.value.twoLeakageCircle = 0;
	RuleFrom.value.twoLeakageAddTime = 0;
	RuleFrom.value.twoLeakageThenNum = 0;
	RuleFrom.value.twoLeakageThenCircle = 0;
};
//计算规则或惩罚规则切换
const handleChangeType = () => {
	let { id, name, project, type } = RuleFrom.value;
	RuleFrom.value = {
		id,
		name,
		project,
		type,
		content: "",
		state: 1,
		finalRule: 0,
		finalCircle: 0,
		bestFiled: 1,
		preliminaryRule: 0,
		finalPeopleNum: 0,
		finalDeductTime: 0,
		singleMinTime: 0,
		isFirstCircled: false,
		leakageRule: 0,
		oneLeakageNum: 0,
		oneLeakageCircle: 0,
		twoLeakageNum: 0,
		twoLeakageType: 0,
		twoLeakageCircle: 0,
		twoLeakageAddTime: 0,
		twoLeakageThenNum: 0,
		twoLeakageAddType: 0,
		twoLeakageThenCircle: 0,
		yellowCardNum: 0,
		yellowCardCircle: 0,
		yellowCardTurnRedCardNum: 0,
		trunRedCardNum: 0,
		redCardNum: 0
	};
};
// 表格配置项
const columns = computed((): Partial<ColumnProps>[] => {
	let data: Partial<ColumnProps>[] = [
		{ prop: "name", label: "规则名称" },
		{ prop: "project", label: "所属项目" },
		{ prop: "type", label: "规则类型" },
		{ prop: "content", label: "规则内容" },
		{ prop: "state", tag: true, label: "状态" },
		{ prop: "createTime", label: "添加时间" },
		{ prop: "operation", label: "操作", width: 200, fixed: "right" }
	];
	return data;
});
//禁用或者启用
const handleClose = ({ id, state }: any) => {
	state = state == "禁用" ? "启用" : "禁用";
	ElMessageBox.alert(`再次确认是否需要${state}规则`, `${state}规则`, {
		confirmButtonText: "确认",
		callback: (action: Action) => {
			if (action == "cancel") return false;
			api.UpdateCompetitionRuleInfoEnableOrDisableApi(id).then(res => {
				let { message } = res.result;
				ElMessage.success(message);
				proTableRef.value.getTableList();
			});
		}
	});
};
const handleEidit = async (id: string) => {
	dialogType.value = "编辑";
	let res = await api.CompetitionRuleInfoDetailsApi(id);
	let { data } = res.result;
	RuleFrom.value = data;
	RuleFrom.value.project = data.projectIds;
	RuleFrom.value.id = id;
	isShow.value = true;
};
//点击取消按钮清空表单数据
const handleCancel = (formEl: FormInstance | undefined) => {
	if (!formEl) return;
	formEl.resetFields();
	isShow.value = false;
	flushed();
};
//修改规则或者添加规则
const requestAddorEidit = () => {
	if (dialogType.value == "添加") {
		api.AddCompetitionRuleInfoApi(RuleFrom.value).then(() => {
			isShow.value = false;
			flushed();
			ElMessage.success(`添加规则成功！`);
			proTableRef.value.getTableList();
		});
		return false;
	}
	api.UpdateCompetitionRuleInfoApi(RuleFrom.value).then(() => {
		isShow.value = false;
		flushed();
		ElMessage.success(`修改规则成功！`);
		proTableRef.value.getTableList();
	});
};
//提交
const handleSubmit = async (formEl: FormInstance | undefined) => {
	if (!formEl) return;
	await formEl.validate((valid: boolean) => {
		let bool = RuleFrom.value.type == 1;
		if (!bool) {
			if (!valid) {
				ElMessage.error("请补充信息！");
				return;
			}
			RuleFrom.value.content = `成绩计算规则：${
				RuleFrom.value.finalRule == 0
					? "比赛时间内，跑圈最多且用时最少者排名靠前；相同圈数看跑圈用时，用时者排名靠前"
					: RuleFrom.value.finalRule == 1
					? "比赛时间内，跑圈最多者排名靠前"
					: "比赛时间内，跑" + RuleFrom.value.finalCircle + "圈，用时最少者排名靠前"
			}。
            预赛进决赛成绩计算规则:预赛3场，取最优${RuleFrom.value.bestFiled}场,${
				RuleFrom.value.preliminaryRule == 0 ? "累计" : "平均"
			}成绩较高者排名靠前，取${RuleFrom.value.finalPeopleNum}名进入决赛;预赛统计：扣除${
				RuleFrom.value.finalDeductTime
			}分钟;单次过点最低时间${RuleFrom.value.singleMinTime}秒钟;${
				RuleFrom.value.isFirstCircled ? "小于单次过点最低时间不加圈，大于单次过点最低时间加圈" : ""
			}`;
			if (RuleFrom.value.finalRule == 2 && !RuleFrom.value.finalCircle) {
				ElMessage.warning("请输入比赛圈数！");
				return false;
			}
			if (RuleFrom.value.bestFiled > 3) {
				ElMessage.warning("场次不能大于3！");
				return false;
			}
			requestAddorEidit();
			return false;
		}
		RuleFrom.value.content = `
      漏标惩罚规则：${
				RuleFrom.value.leakageRule == 0
					? "漏标" + RuleFrom.value.oneLeakageNum + "个，扣" + RuleFrom.value.oneLeakageCircle + "圈"
					: "漏标第" +
					  RuleFrom.value.twoLeakageNum +
					  "个" +
					  (RuleFrom.value.twoLeakageType == 0
							? "扣圈" + RuleFrom.value.twoLeakageCircle + "圈，"
							: "加时" + RuleFrom.value.twoLeakageAddTime + "秒，") +
					  "此后则每漏标" +
					  RuleFrom.value.twoLeakageThenNum +
					  "个，" +
					  (RuleFrom.value.twoLeakageAddType ? "加时" : "扣圈") +
					  RuleFrom.value.twoLeakageThenCircle +
					  (RuleFrom.value.twoLeakageAddType ? "秒" : "圈")
			}。
      红黄牌惩罚规则：${RuleFrom.value.yellowCardNum}个黄牌，扣${RuleFrom.value.yellowCardCircle}圈；${
			RuleFrom.value.yellowCardTurnRedCardNum
		}个黄牌，得${RuleFrom.value.trunRedCardNum}红牌；${RuleFrom.value.redCardNum}红牌本场成绩无效。
      `;
		if (!RuleFrom.value.name) {
			ElMessage.warning("请输入规则名称！");
			return false;
		}
		if (!RuleFrom.value.project) {
			ElMessage.warning("请选择规则所属项目！");
			return false;
		}
		if (RuleFrom.value.leakageRule == 0 && RuleFrom.value.oneLeakageNum < 1) {
			ElMessage.warning("请输入漏标个数！");
			return false;
		}
		if (RuleFrom.value.leakageRule == 0 && RuleFrom.value.oneLeakageCircle < 1) {
			ElMessage.warning("请输入漏标惩罚圈数！");
			return false;
		}
		if (RuleFrom.value.leakageRule == 1 && RuleFrom.value.twoLeakageNum < 1) {
			ElMessage.warning("请输入漏标个数！");
			return false;
		}
		if (RuleFrom.value.leakageRule == 1 && RuleFrom.value.twoLeakageType == 0 && RuleFrom.value.twoLeakageCircle < 1) {
			ElMessage.warning("请输入漏标惩罚扣圈个数！");
			return false;
		}
		if (RuleFrom.value.leakageRule == 1 && RuleFrom.value.twoLeakageType == 1 && RuleFrom.value.twoLeakageAddTime < 1) {
			ElMessage.warning("请输入漏标惩罚加时秒数！");
			return false;
		}
		if (RuleFrom.value.leakageRule == 1 && RuleFrom.value.twoLeakageThenNum < 1) {
			ElMessage.warning("请输入此后漏标个数！");
			return false;
		}
		if (RuleFrom.value.leakageRule == 1 && RuleFrom.value.twoLeakageThenCircle < 1) {
			ElMessage.warning(`请输入漏标惩罚加${RuleFrom.value.twoLeakageAddType ? "秒" : "圈"}数！`);
			return false;
		}
		if (RuleFrom.value.yellowCardNum < 1) {
			ElMessage.warning(`请输入黄牌个数！`);
			return false;
		}
		if (RuleFrom.value.yellowCardCircle < 1) {
			ElMessage.warning(`请输入得黄牌后扣除的圈数！`);
			return false;
		}
		if (RuleFrom.value.yellowCardTurnRedCardNum < 1) {
			ElMessage.warning(`请输入获取红牌的黄牌数量！`);
			return false;
		}
		if (RuleFrom.value.trunRedCardNum < 1) {
			ElMessage.warning(`请输入${RuleFrom.value.yellowCardTurnRedCardNum}黄牌得多少红牌！`);
			return false;
		}
		if (RuleFrom.value.redCardNum < 1) {
			ElMessage.warning(`请输入多少红牌成绩将无效！`);
			return false;
		}
		requestAddorEidit();
	});
};
</script>
<style scoped lang="scss">
.rulrBox {
	margin: 15px 0px;
	background-color: #d8d8d8;
	padding: 15px;

	.rulesTitle {
		background-color: #d8d8d8;
		height: 30px;

		span {
			font-size: 14px;
			position: relative;
			line-height: 30px;
			text-indent: 2em;

			&::before {
				content: "";
				position: absolute;
				width: 2px;
				height: 100%;
				background-color: #808080;
				left: -5px;
				bottom: 0;
			}
		}
	}

	.item {
		padding: 10px;
		padding-left: 20px;
		background-color: #fff;
	}
}
</style>
